<%--
  Created by IntelliJ IDEA.
  User: 15890741124
  Date: 2022/8/15
  Time: 16:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="../common.jsp"%>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>测试者登录</title>

    <style>
        html,
        body {
            background: rgba(2, 2, 1, 0.93);
            margin: 0;
            padding: 0;
        }

        canvas {
            width: 100%;
            height: 100%;
            position: absolute;
        }

        /* Demo Buttons Style */
        .codrops-demos {
            font-size: 0.8em;
            text-align: center;
            position: absolute;
            z-index: 99;
            width: 96%;
        }

        .codrops-demos a {
            display: inline-block;
            margin: 0.35em 0.1em;
            padding: 0.5em 1.2em;
            outline: none;
            text-decoration: none;
            text-transform: uppercase;
            letter-spacing: 1px;
            font-weight: 700;
            border-radius: 2px;
            font-size: 110%;
            border: 2px solid transparent;
            color: #fff;
        }

        .codrops-demos a:hover,
        .codrops-demos a.current-demo {
            border-color: #383a3c;
        }

        /*form表单*/
        .layui-form {
            width: 100%;
            margin: 0;
            padding: 0;
        }

        .container {
            width: 420px;
            height: 280px;
            min-height: 280px;
            max-height: 320px;
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            margin: auto;
            padding: 20px;
            z-index: 130;
            border-radius: 8px;
            background-color: rgba(255, 255, 255, 0.11);
            font-size: 16px;
        }

        .contain {
            bottom: 0;
            right: 0;
            margin: auto;
            padding: 20px;
            z-index: 130;
            border-radius: 8px;
            background-color: rgba(255, 255, 255, 0.11);
            font-size: 16px;
            overflow: hidden;
        }

        .topic {
            text-align: center;
            color: #ffffff;
            font-size: 25px;
            font-weight: normal;
        }

        .my-form-item {
            margin: 25px -50px;
            background-color: rgba(0, 0, 0, 0);
        }

        .my-input {
            border-radius: 45px;
            width: 300px;
            height: 40px;
            font-size: 15px;
            color: white;
            background-color: rgba(255, 255, 255, 0);
            border: rgba(255, 255, 255, 0.2) 2px solid;
            text-align: center;
        }

        .mine-input {
            border-radius: 45px;
            width: 300px;
            height: 40px;
            font-size: 15px;
            border: rgba(0, 0, 0, 0.5) 2px solid;
            text-align: center;
        }

        .layui-btn {
            border-radius: 45px;
            width: 300px;
            height: 40px;
            font-size: 15px;
            color: white;
            background-color: rgba(0, 0, 0, 0);
            border: rgba(255, 255, 255, 0.2) 2px solid;
        }
        .font-set{
            font-size: 13px;
            text-decoration: none;
            margin-left: 100px;
            color: white;
        }

        /*a:hover{*/
        /*    text-decoration: underline;*/
        /*}*/
        @media screen and (max-device-width: 600px) {

            .container {
                width: 100%;
                margin-left: 0;
                margin-right: 0;

            }

            .my-form-item {
                margin: 25px -100px;
                background-color: rgba(0, 0, 0, 0);
            }
        }
    </style>
    <link id="layuicss-layer" rel="stylesheet" href="${pageContext.request.contextPath}/static/layui/css/modules/layer/default/layer.css" media="all">
</head>
<body>

<canvas width="1536" height="754"></canvas>
<form class="layui-form" id="login" >
    <!-- 提示：如果你不想用form，你可以换成div等任何一个普通元素 -->
    <div class="container" >
        <p class="topic">登录</p>
        <div class="layui-form-item my-form-item">
            <div class="layui-input-block">
                <input class="layui-input my-input " type="text" name="name" lay-verify="required|myName"
                       placeholder="请输入姓名" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item my-form-item">
            <div class="layui-input-block">
                <input class="layui-input my-input" type="text" name="phone" lay-verify="required|phone"
                   id="myPhone"    placeholder="请输入手机号" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item my-form-item">
            <div class="layui-input-block">
                <input class="layui-input my-input" type="text" name="testCode" lay-verify="required"
                       placeholder="邀请码" autocomplete="off">
            </div>
        </div>
        <div class="layui-form-item my-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit="" lay-filter="testFormFilter">登录</button>
            </div>
        </div>
    </div>
</form>

<script>
    var type = null
    layui.use(['form', 'layer', 'jquery'], function() {
        var form = layui.form;
        var layer = layui.layer;
        var $ = layui.jquery;


        //登录按钮
        form.on('submit(testFormFilter)', function(data) {
            var loading = layer.msg('正在登录请稍后。。。', {icon: 1, shade: 0.3, time:0});
            $.ajax({
                url: "${pageContext.request.contextPath}/test/testLogin.do"
                , data: data.field
                , dataType: "json"
                , type: "POST"
                , success: function (dat) {
                    if (dat.code == 0) {
                        layer.closeAll();
                        window.location.href = "${pageContext.request.contextPath}/views/front/testQuestion.jsp"
                    }else {
                        layer.msg(dat.msg,{icon: 5,time:10 });
                        // layer.msg(dat.msg);
                        <%--window.location.href = "${pageContext.request.contextPath}/views/login.jsp"--%>
                    }
                    // layer.msg(dat.msg);
                }
            });
            return false; //阻止表单跳转。
        });

//校验姓名
        form.verify({
            myName: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[\u4E00-\u9FA5]{2,4}$").test(value)){
                    return '姓名只能是2到4位的汉字';
                }

            }
        });

    });

    $(function() {
        var canvas = document.querySelector('canvas'),
            ctx = canvas.getContext('2d')
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
        ctx.lineWidth = .3;
        ctx.strokeStyle = (new Color(150)).style;

        var mousePosition = {
            x: 30 * canvas.width / 100,
            y: 30 * canvas.height / 100
        };

        var dots = {
            nb: 750,
            distance: 50,
            d_radius: 100,
            array: []
        };

        function colorValue(min) {
            return Math.floor(Math.random() * 255 + min);
        }

        function createColorStyle(r, g, b) {
            return 'rgba(' + r + ',' + g + ',' + b + ', 0.8)';
        }

        function mixComponents(comp1, weight1, comp2, weight2) {
            return (comp1 * weight1 + comp2 * weight2) / (weight1 + weight2);
        }

        function averageColorStyles(dot1, dot2) {
            var color1 = dot1.color,
                color2 = dot2.color;

            var r = mixComponents(color1.r, dot1.radius, color2.r, dot2.radius),
                g = mixComponents(color1.g, dot1.radius, color2.g, dot2.radius),
                b = mixComponents(color1.b, dot1.radius, color2.b, dot2.radius);
            return createColorStyle(Math.floor(r), Math.floor(g), Math.floor(b));
        }

        function Color(min) {
            min = min || 0;
            this.r = colorValue(min);
            this.g = colorValue(min);
            this.b = colorValue(min);
            this.style = createColorStyle(this.r, this.g, this.b);
        }

        function Dot() {
            this.x = Math.random() * canvas.width;
            this.y = Math.random() * canvas.height;

            this.vx = -.5 + Math.random();
            this.vy = -.5 + Math.random();

            this.radius = Math.random() * 2;

            this.color = new Color();

        }

        Dot.prototype = {
            draw: function() {
                ctx.beginPath();
                ctx.fillStyle = this.color.style;
                ctx.arc(this.x, this.y, this.radius, 0, Math.PI * 2, false);
                ctx.fill();
            }
        };

        function createDots() {
            for (i = 0; i < dots.nb; i++) {
                dots.array.push(new Dot());
            }
        }

        function moveDots() {
            for (i = 0; i < dots.nb; i++) {

                var dot = dots.array[i];

                if (dot.y < 0 || dot.y > canvas.height) {
                    dot.vx = dot.vx;
                    dot.vy = -dot.vy;
                } else if (dot.x < 0 || dot.x > canvas.width) {
                    dot.vx = -dot.vx;
                    dot.vy = dot.vy;
                }
                dot.x += dot.vx;
                dot.y += dot.vy;
            }
        }

        function connectDots() {
            for (i = 0; i < dots.nb; i++) {
                for (j = 0; j < dots.nb; j++) {
                    i_dot = dots.array[i];
                    j_dot = dots.array[j];

                    if ((i_dot.x - j_dot.x) < dots.distance && (i_dot.y - j_dot.y) < dots.distance && (i_dot.x -
                        j_dot.x) > -dots.distance && (i_dot.y - j_dot.y) > -dots.distance) {
                        if ((i_dot.x - mousePosition.x) < dots.d_radius && (i_dot.y - mousePosition.y) < dots
                            .d_radius && (i_dot.x - mousePosition.x) > -dots.d_radius && (i_dot.y - mousePosition
                            .y) > -dots.d_radius) {
                            ctx.beginPath();
                            ctx.strokeStyle = averageColorStyles(i_dot, j_dot);
                            ctx.moveTo(i_dot.x, i_dot.y);
                            ctx.lineTo(j_dot.x, j_dot.y);
                            ctx.stroke();
                            ctx.closePath();
                        }
                    }
                }
            }
        }

        function drawDots() {
            for (i = 0; i < dots.nb; i++) {
                var dot = dots.array[i];
                dot.draw();
            }
        }

        function animateDots() {
            ctx.clearRect(0, 0, canvas.width, canvas.height);
            moveDots();
            connectDots();
            drawDots();

            requestAnimationFrame(animateDots);
        }

        $('canvas').on('mousemove', function(e) {
            mousePosition.x = e.pageX;
            mousePosition.y = e.pageY;
        });

        $('canvas').on('mouseleave', function(e) {
            mousePosition.x = canvas.width / 2;
            mousePosition.y = canvas.height / 2;
        });

        createDots();
        requestAnimationFrame(animateDots);
    });
</script>


</body>
</html>

